<template>
    <div>
        <!--    搜索表单-->
        <div style="margin-bottom: 20px">
            <el-divider></el-divider>
            <div style="float: left;margin-top: -10px">
                <i style="font-size: x-large" class="el-icon-document-checked"></i><span
                    style="margin-left:10px;font-weight:bold;font-size:x-large">结果查询</span>
            </div>
            <el-form style="float:left;margin-left:35px;margin-top:-16px;" :inline="true" class="demo-form-inline">
                <el-form-item style="font-weight:bold;font-size:x-large" label="查询类型">
                    <el-select v-model="queryType" placeholder="选择查询类型">
                        <el-option label="检查" value="检查"></el-option>
                        <el-option label="检验" value="检验"></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <br>
        </div>
        <el-divider></el-divider>
        <br>
        <div>
            <span style="float:left;margin-left:10px;margin-top:-10px;font-size: larger;font-weight: bold">患者信息查询</span>
            <el-form style="float:left;margin-left:2px;margin-top:34px;" :inline="true" class="demo-form-inline">
                <i style="float:left;margin-top:10px;" class=" el-icon-tickets "></i> <el-form-item style="margin-left:5px;"
                    label="病历号:">
                    <el-input v-model="caseNumber" style="width: 270px;float: left;" placeholder="患者病历号"
                        clearable></el-input>
                </el-form-item>
            </el-form>
            <el-form style="float:left;margin-left:11px;margin-top:53px;" :inline="true" class="demo-form-inline">
                <i style="float:left;margin-left:11px;margin-top:-2px;" class="el-icon-user"></i> <el-form-item
                    style="margin-top:-14px;margin-left:10px;" label="患者名:">
                    <el-input v-model="realName" style="width: 270px;float: left;margin-left:-2px;margin-top:-4px"
                        placeholder="患者姓名" clearable></el-input>
                    <el-button style="float:left;margin-left:28px;margin-top:0px;width: 100px" type="primary"
                        @click="getOne">确定</el-button>
                </el-form-item>
            </el-form>

        </div>
        <div class="verify">
            <br> <br> <br> <br> <br>
            <span style="float:left;margin-left:-857px;margin-top:67px;font-size: larger;font-weight: bold">患者信息确认</span>
            <el-button style="float:left;margin-left:28px;margin-top:-10px;width: 100px" type="primary"
                        @click="getResult">结果搜索</el-button>
            <br> <br> <br> <br> <br> <br>
            <el-form style="float:left;margin-left:11px;margin-top:53px;" :inline="true" class="demo-form-inline">
                <i style="float:left;margin-left:11px;margin-top:23px;" class="el-icon-user"></i> <el-form-item
                    style="margin-top:10px;margin-left:10px;" label="挂号id:">
                    <el-input v-model="registerId" style="width: 130px;float: left;" placeholder="挂号id"
                        :disabled="true"></el-input>
                </el-form-item>
            </el-form>
            <el-form style="float:left;margin-left:2px;margin-top:34px;" :inline="true" class="demo-form-inline">
                <i style="float:left;margin-top:45px;" class=" el-icon-tickets "></i> <el-form-item
                    style="margin-top:31px;margin-left:5px;" label="患者名:">
                    <el-input v-model="realName" style="width: 270px;float: left;" placeholder="患者名"
                        :disabled="true"></el-input>
                </el-form-item>
            </el-form>
            <el-form style="float:left;margin-left:11px;margin-top:53px;" :inline="true" class="demo-form-inline">
                <i style="float:left;margin-left:5px;margin-top:23px;" class="el-icon-date"></i> <el-form-item
                    style="margin-top:10px;margin-left:10px;" label="年龄:">
                    <el-input v-model="age" style="width: 130px;float: left;margin-top:0px" placeholder="年龄"
                        :disabled="true"></el-input>
                </el-form-item>
            </el-form>
            <el-form style="float:left;margin-left:21px;margin-top:53px;" :inline="true" class="demo-form-inline">
                <i style="float:left;margin-left:5px;margin-top:23px;" class="el-icon-male"></i> <el-form-item
                    style="margin-top:10px;margin-left:10px;" label="性别:">
                    <el-input v-model="gender" style="float: left;margin-top:0px" placeholder="性别"
                        :disabled="true"></el-input>
                </el-form-item>
            </el-form>

        </div>
        <br><br>
        <el-divider></el-divider>
        <el-table :data="ResultTable" style="width: 100%">
            <el-table-column label="项目名称" prop="techName">
            </el-table-column>
            <el-table-column label="检查部位" prop="checkPosition">
            </el-table-column>
            <el-table-column label="目的要求" prop="checkInfo">
            </el-table-column>
            <el-table-column label="检查结果" prop="checkResult">
            </el-table-column>
            <!-- <el-table-column label="检查医生" prop="checkDoctor">
            </el-table-column> -->
            <el-table-column label="检查时间" prop="checkTime">
            </el-table-column>
            <el-table-column label="状态" prop="checkState">
            </el-table-column>
        </el-table>

    </div>
</template>
<script>
import axios from 'axios'
export default {
    data() {
        return {
            queryType: '',
            caseNumber: '',
            realName: '',
            registerId: '',
            age: '',
            gender: '',
            ResultTable: [],
        }

    },
    methods: {
        //确定搜索一个挂号患者信息
        async getOne() {
            //确定搜索一个挂号患者信息
            //参数:String caseNumber,String realName
            await axios.get("http://127.0.0.1:8088/register/getOne", { params: { caseNumber: this.caseNumber, realName: this.realName } }).then((res) => {
                console.log("患者挂号信息:  " + res.data.data)
                //绑定数据 
                this.realName = res.data.data.realName
                this.registerId = res.data.data.id
                this.age = res.data.data.age
                this.gender = res.data.data.gender
                this.caseNumber = res.data.data.caseNumber
            })
        },

        //搜索一个患者所有的检查项目
        async getCheckByRegisterId() {
            await axios.get("http://127.0.0.1:8088/check/getCheckByRegisterId", { params: { registerId: this.registerId } }).then((res) => {
                console.log(res.data.data)
                //绑定数据
                this.ResultTable = res.data.data
                this.$message({
                    message: '检查项目搜索成功',
                    type: 'success'
                });
            })
        },

        //搜索一个患者所有的检验项目
        async getInspectionByRegisterId() {
            await axios.get("http://127.0.0.1:8088/inspection/getInspectionByRegisterId", { params: { registerId: this.registerId } }).then((res) => {
                console.log(res.data.data)
                //绑定数据
                this.ResultTable = res.data.data
                this.$message({
                    message: '检验项目搜索成功',
                    type: 'success'
                });
            })
        },

        getResult() {
            if (this.queryType == '检查') {
                this.getCheckByRegisterId();
            }
            else if (this.queryType == '检验') {
                this.getInspectionByRegisterId()
            }
        }
    }
}
</script>
<style scoped></style>